﻿#pragma once

#define DGGS_KERNEL_EXPORTS

#ifdef _MSC_VER
#ifdef DGGS_KERNEL_EXPORTS
#define DGGS_KERNEL_API __declspec(dllexport)
#else
#define DGGS_KERNEL_API __declspec(dllimport)
#endif
#else   // Linux GCC
#define DGGS_KERNEL_API
#endif

#include"../LibDGGSBase/DGGSDefine.hpp"


_NNU_DGGS_BEGIN
using namespace Base;
namespace Kernel
{
    class QueryResult;

    /// <summary>
    /// DGGS核心接口定义
    /// </summary>
    Interface IDGGSKernel
    {
        /// <summary>
        /// 格网核心库初始化
        /// </summary>
        virtual void init() = 0;

        /// <summary>
        /// 格网核心库卸载
        /// </summary>
        virtual void release() = 0;

        /// <summary>
        /// 地理坐标转格网编码
        /// </summary>
        /// <param name="coords"></param>
        /// <param name="elementType"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        virtual bool encode(GeoCoord coords, DGGSElementCode& code) = 0;

        /// <summary>
        /// 格网编码转地理坐标
        /// </summary>
        /// <param name="code"></param>
        /// <param name="elementType"></param>
        /// <param name="coords"></param>
        /// <returns></returns>
        virtual bool decode(DGGSElementCode code, GeoCoord& coords) = 0;

        /// <summary>
        /// 格网编码的关系查询
        /// </summary>
        /// <param name="queryType"></param>
        /// <param name="code"></param>
        /// <param name="iter"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        virtual bool query(DGGSTopoType queryType, DGGSElementCode code, DGGSElementCodeIter*& iter, int& elementNum) = 0;

        /// <summary>
        /// 格网编码的关系查询
        /// </summary>
        /// <param name="queryType"></param>
        /// <param name="code"></param>
        /// <param name="queryResult"></param>
        /// <returns></returns>
        bool query(DGGSTopoType queryType, DGGSElementCode code, QueryResult& result);
    };


    /// <summary>
    /// 创建GridKernel类对象
    /// </summary>
    /// <param name="gridType">网格类型</param>
    /// <returns></returns>, int level
    extern "C" DGGS_KERNEL_API IDGGSKernel* CreateKernelObj(DGGSGridType gridType);

    /// <summary>
    /// 销毁GridKernel类对象
    /// </summary>
    /// <param name="pKernel"></param>
    extern "C" DGGS_KERNEL_API  void DestroyKernelObj(IDGGSKernel * &pKernel);

}
_NNU_DGGS_END